package cn.signalpha.modules.shop.controller.seller;

import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.core.mp.support.Condition;
import cn.signalpha.core.mp.support.Query;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.modules.shop.entity.PlaceLevel;
import cn.signalpha.modules.shop.service.PlaceLevelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 控制器
 *
 * @author signalpha
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SHOP_NAME + "/sys-seller/place/level")
@Api(value = "分销员等级", tags = "分销员等级")
public class SpiPlaceLevelController extends BaseController {

	private final PlaceLevelService placeLevelService;

    @GetMapping("/page")
    @ApiImplicitParams({
        @ApiImplicitParam(name="level", dataType = "string", value = "等级"),
        @ApiImplicitParam(name="name", dataType = "string", value = "名称"),
    })
    @ApiOperation(value = "分页", notes = "")
    public R<IPage<PlaceLevel>> page(@ApiIgnore @RequestParam Map<String, Object> params, Query query) {
        QueryWrapper<PlaceLevel> wrapper = placeLevelService.selectPlaceLevelWrapper(params);
        return R.data(placeLevelService.page(Condition.getPage(query), wrapper));
    }

    @GetMapping("/list")
    @ApiOperation(value = "列表", notes = "")
    public R<List<PlaceLevel>> list(@ApiIgnore @RequestParam Map<String, Object> params) {
        return R.data(placeLevelService.list(placeLevelService.selectPlaceLevelWrapper(params)));
    }

}
